package main

func searchInsert(nums []int, target int) int {
	l, r := 0, len(nums)-1
	for l <= r {
		m := (r + l) / 2
		if nums[m] == target {
			return m
		} else if nums[m] > target {
			r = m - 1
		} else {
			l = m + 1
		}
	}
	return r + 1
}

func main() {
	var s = []int{1, 21, 32, 42, 50}
	searchInsert(s, 25)
}
